<html>
<?php
    session_start();
    if($_SESSION['login']!='y'){
        $url = 'login.html';
        Header("Location: $url");
    }
    include('class.php');
    $db = new DB();
    $result = $db->getUserinfo($_SESSION['id'],$_SESSION['pass']);
    $row = mysql_fetch_array($result);
    $_SESSION['name']=$row['name'];
    $state = $db->getUserstate($_SESSION['name'],$_SESSION['id']);
    $_SESSION['state']=$state;
    //update the age of the staff
    $cb = $db->getUserbirth($_SESSION['name'],$_SESSION['id']);
    $cbirth = mysql_fetch_array($cb);
    $y=$cbirth['year'];
    $m=$cbirth['month'];
    $time = time();
    $date = getdate($time);
    $year = $date["year"];
    $mon = $date["mon"];
    if($m>$mon){
    $age=$year-$y-1;
    }
    else $age=$year-$y;
    $db->updatebirth($age,$_SESSION['id']);
    //get the current birthday
    $b = $db->getUserbirth($_SESSION['name'],$_SESSION['id']);
    $birth = mysql_fetch_array($b);
	$dd=$db->haveAssignment($_SESSION['name'],$_SESSION['id']);
	$lt=$db->checkIn($_SESSION['name'],$_SESSION['id']);
	$db->close();
    ?>

	<head>
		<link rel="stylesheet" href="bootstrap-theme.css">
		<link rel="stylesheet" href="bootstrap-theme.min.css">
		<link rel="stylesheet" href="bootstrap.min.css">
		<link rel="stylesheet" href="bootstrap.css">
		<link rel="stylesheet" href="DIY.css">
		<script>
			function jingao() {
				alert('you have unfinished assignment and remember to check your attendance');
			}

			function qiandao() {
				alert('remember to check your attendance');
			}

		</script>
	</head>

	<body>
		<div class="container">
			<ul class="nav nav-tabs">
				<li role="presentation" class="active"><a href="User.php">Staff Information</a></li>
				<li role="presentation"><a href="CheckAttendanceForStaff.php">Check Attendance</a></li>
				<li role="presentation"><a href="Attendancechart.php">Attendance Statistics</a></li>
				<li role="presentation"><a href="DailyAssignmentForStaff.php">Daily Assignment</a></li>
				<li role="presentation"><a href="BulletinForStaff.php">Bulletin</a></li>
				<a class="logout" href="Logout.php">Log out</a>
				<label class="logout">Company Name</label>

			</ul>
			<div class="panel panel-default">

			</div>
			<div class="panel panel-default">
				<div class="panel-heading">
					<h3 class="panel-title">Staff Information</h3>
				</div>
				<div class="panel-body">
					<div class="container2">
						<label class="font">Name:&nbsp;&nbsp;&nbsp;<?php echo $row['name']?></label>
						<div class="container3">
							<img src="<?php echo $row['image']?> " style="width:200px;height:200px;">
						</div>
						<br/>
						<label class="pmargin font">Sex:&nbsp;&nbsp;&nbsp;<?php echo $row['sex']?></label><br/>
						<label class="pmargin font">Birth:&nbsp;&nbsp;&nbsp;<?php echo $birth['year']." "; echo $birth['month']." "; echo $birth['date'];?></label><br/>
						<label class="pmargin font">Level:&nbsp;&nbsp;&nbsp;<?php echo $row['level']?></label><br/>
						<label class="pmargin font">Position:&nbsp;&nbsp;&nbsp;<?php echo $row['position']?></label><br/>
						<label class="pmargin font">State:&nbsp;&nbsp;&nbsp;<?php echo $state?></label><br/>
						<label class="pmargin font">Age:&nbsp;&nbsp;&nbsp;<?php echo $birth['age']?></label><br/>
					</div>


				</div>
			</div>
		</div>
		<script>
			var a = <?php echo $dd;?>;
			var b = <?php echo $lt;?>;
			console.log(a);
			if (a == 1) {
				jingao();
			} else {
				if (b == 1)
					qiandao();
			}

		</script>
	</body>

</html>
